package com.rgp.apipassenger.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-10 19:15
 */
@RestController
public class TestController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @GetMapping("test")
    public String test(){
        HashMap<String, String> map = new HashMap<>();
        map.put("test","success");
        String json = JSON.toJSONString(map);
        return json;
    }

    @GetMapping("test/redis")
    public String testRedis(){
        //set
//        stringRedisTemplate.opsForValue().set("key","value");
        //get
        String value = stringRedisTemplate.opsForValue().get("key");
        System.out.println("value");
        return new String("key=" + value);
    }
}
